/**
 Copyright will be fixed soon.
 Author: Hiroshi Ota.
 $Date: $
 $Revision: $
*/

#include "Sensor.h"

#ifndef _BRICKOS_

Sensor::Sensor(const Port port, bool makeActive, ISimulatorControl* sc, char* name)
:simCon(sc), myPort(port)
{
	if (simCon!=0) {
		simCon->setSensorMode(myPort, makeActive);
		if (name!=0) {
			simCon->setSensorName(port, name);
		}
	}
}

Sensor::~Sensor(void)
{
}

unsigned int Sensor::get() const
{
	int result =0;
	if (simCon!=0) {
		result = simCon->getSensorValue(myPort);
	}
	return result;

}

void Sensor::mode(bool makeActive) const
{
	if (simCon!=0) {
		simCon->setSensorMode(myPort, makeActive);
	}
}

void Sensor::passive() const
{
	mode(false);
}

void Sensor::active() const
{
	mode(true);
}

#endif // _BRICKOS_
